from django.db import models
from django.utils import timezone


class UserInfo(models.Model):
    """基本信息"""
    SEX_CHOICES = [
        (0, '未知'),
        (1, '男'),
        (2, '女'),
    ]
    name = models.CharField(verbose_name='姓名', max_length=32, null=False, default='')
    sex = models.SmallIntegerField(verbose_name='性别', default=1, choices=SEX_CHOICES, )
    age = models.SmallIntegerField(verbose_name='年龄', default=None, blank=True, null=True)
    owner = models.OneToOneField('auth.User', on_delete=models.SET_NULL, null=True, blank=True, verbose_name='关联账户')
    avatar = models.ImageField(upload_to='avatar/%Y/%m/%d', null=True, blank=True, help_text='头像',
                               verbose_name='用户头像')
    background = models.ImageField(upload_to='background/%Y/%m/%d', null=True, blank=True, help_text='个人界面背景图片',
                                   verbose_name='背景图片')

    class Meta:
        abstract = True


class CommonModel(models.Model):
    """时间信息"""
    created_at = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
    updated_at = models.DateTimeField(verbose_name='删除时间', auto_now=True)

    class Meta:
        abstract = True


class introduce(models.Model):
    name = models.CharField(verbose_name='名称', max_length=30, null=False, default='', unique=True)
    desc = models.TextField(verbose_name='描述', max_length=30, null=True, blank=True)

    class Meta:
        abstract = True


class UpTime(models.Model):
    create_at = models.DateTimeField(verbose_name='上传时间', default=timezone.now)
    updated_at = models.DateTimeField(verbose_name='更改时间', auto_now=True)

    class Meta:
        abstract = True
